package me.cangming.cmfixsdk;

import android.database.Cursor;

import java.io.Closeable;
import java.io.IOException;

/**
 * @date 创建时间：2019-09-10
 * @auther cangming
 * @Description 工具类: IO 流对象相关 API  : 关闭流对象 等
 */
public class IOUtils {

    private IOUtils() {
    }

    public static void close(Closeable stream) {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


    public static void close(Cursor cursor) {
        if (cursor != null) {
            cursor.close();
        }
    }

    public static void close(Closeable... streams) {
        for (Closeable stream : streams) {
            close(stream);
        }
    }


    public static void closeQuietly(Closeable stream) {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException ignored) {
            }
        }
    }

    public static void closeQuietly(Closeable... streams) {
        for (Closeable stream : streams) {
            close(stream);
        }
    }
}
